﻿using System;
using System.Windows;
using System.Windows.Data;
using System.Windows.Documents;
using System.Globalization;

namespace OverlakeApp.Converters
{
#if PC
    using AppService = OverlakeWSTester.AppService;
#endif

    /// <summary>
    /// 
    /// </summary>
    public class ClassToBlockNameConverter : IValueConverter
    {
        /// <summary>
        /// Convert from a class to its block name.
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            AppService.Section s = value as AppService.Section;
            string retval = s.MeetsGradeSeq + " Block";

            if (s.MeetTerms.Count != 4)
            {
                if(s.MeetTerms[0].Name.EndsWith("1"))
                {
                    retval = retval + ", 1st Semester";
                }
                else
                {
                    retval = retval + ", 2nd Semester";
                }
            }

            return retval;
        }

        /// <summary>
        /// Not implemented.
        /// </summary>
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }
    }
}
